package com.cashg.dao;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.provider.BaseColumns;

public class DatabaseHelper extends SQLiteOpenHelper {
	
	static int DATABASE_VERSION = 2;
	public static final String DATABASE_NAME = "cashg.db";

    DatabaseHelper(Context context, String name,
            SQLiteDatabase.CursorFactory factory)
{
super(context, name, factory, DATABASE_VERSION);
}

@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
createTable(sqLiteDatabase);
}

private void createTable(SQLiteDatabase sqLiteDatabase) {
String createvideoTable =
 "CREATE TABLE " + CashGEntities.Merchant.MERCHANT_TABLE_NAME + " (" +
         BaseColumns._ID +
         " INTEGER PRIMARY KEY AUTOINCREMENT, " +
         CashGEntities.Merchant.NAME_COLUMN + " TEXT, " +
         CashGEntities.Merchant.THUMBNAIL + " TEXT, " +
         CashGEntities.Merchant.TIMESTAMP_COLUMN + " TEXT " +
         ");";
sqLiteDatabase.execSQL(createvideoTable);
}

@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldv,
           int newv)
{
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " +
		CashGEntities.Merchant.MERCHANT_TABLE_NAME + ";");
createTable(sqLiteDatabase);
}
}
